package com.uvlab.sitespot.service.user;

import org.springframework.web.client.RestTemplate;
import java.util.LinkedHashMap;

/**
 * Created by Administrator on 2016/7/4 0004.
 */
public class JxUserService {

    private LinkedHashMap items =new LinkedHashMap();
    RestTemplate restTemplate;
    private  String url="http://localhost:8082";
    public JxUserService(){

    }

    public void init(String url){
        this.url=url;
    }
    public LinkedHashMap find() {
        restTemplate= new RestTemplate();
        items = restTemplate.getForObject(url+"/user", LinkedHashMap.class);
        return  this.items;
    }

    public JxUser get(String id){
        restTemplate=new RestTemplate();
        return restTemplate.getForObject(url+"/user/"+id,JxUser.class);

    }
    public JxUser add(JxUser user) {
        restTemplate= new RestTemplate();
        return  restTemplate.postForObject(url+"/user",user,JxUser.class);
    }

    public  void remove(String id){
        restTemplate= new RestTemplate();
        restTemplate.delete(url+"/user/"+id);
    }

    public void set(String id,JxUser user){
        restTemplate=new RestTemplate();
        restTemplate.put(url+"/user/"+id,user);
    }
}
